package com.shop.controller;

import com.shop.common.ResponseResult;
import com.shop.entity.Goods;
import com.shop.entity.Orders;
import com.shop.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
@CrossOrigin
@RestController
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    @GetMapping("/orders")
    public ResponseResult selectPage(@RequestParam(required = false)String query,
                                     @RequestParam(required = false)Integer pagenum,
                                     @RequestParam(required = false)Integer pagesize){
        return ordersService.selectPage(pagenum,pagesize,query);
    }

    @PutMapping("/orders/{id}")
    public ResponseResult updateOrders(@PathVariable Integer id, @RequestBody Orders orders) throws Exception {
        return ordersService.updateOrders(id, orders);
    }

    @GetMapping("/orders/{id}")
    public ResponseResult selectOne(@PathVariable Integer id){
        return ordersService.selectOne(id);
    }

//    @GetMapping("/orders/{id}")
//    public ResponseResult selectGoods(@PathVariable Integer id){
//        return ordersService.selectGoods(id);
//    }
}
